# from selenium import webdriver
# from selenium.webdriver.common.by import By
# from selenium.webdriver.common.action_chains import ActionChains
# import time
#
# driver = webdriver.Chrome(executable_path=r"D:\python\chromedriver.exe")
# driver.get("http://121.43.169.97:8848/pageA.html")
# # 定位用户名输入框
# username_input = driver.find_element(By.NAME, "userA")
# # 初始化ActionChains对象
# action = ActionChains(driver)
# # 执行鼠标右键操作
# action.context_click(username_input).perform()
# time.sleep(3)
# driver.quit()

# from selenium import webdriver
# from selenium.webdriver.common.by import By
# from selenium.webdriver.common.action_chains import ActionChains
# import time
#
# from selenium import webdriver
# from selenium.webdriver.common.by import By
# from selenium.webdriver.common.action_chains import ActionChains
# import time
# driver = webdriver.Chrome(executable_path=r"D:\python\chromedriver.exe")
# driver.get("http://121.43.169.97:8848/pageA.html")
# # 定位并输入用户名
# username_input = driver.find_element(By.NAME, "userA")
# username_input.send_keys("admin")
# time.sleep(3)  # 暂停3秒
# # 初始化ActionChains并执行双击操作
# action = ActionChains(driver)
# action.double_click(username_input).perform()
# time.sleep(3)
# driver.quit()


# from selenium import webdriver
# from selenium.webdriver.common.by import By
# from selenium.webdriver.common.action_chains import ActionChains
# import time
#
# driver = webdriver.Chrome(executable_path=r"D:\python\chromedriver.exe")
# driver.get("file:///C:/Users/小莹莹/PycharmProjects/UI自动化测试/drag.html")
# time.sleep(3)
# source = driver.find_element(By.ID, "redBox")
# target = driver.find_element(By.ID, "blueBox")
# action = ActionChains(driver)
# action.drag_and_drop(source, target).perform()
# time.sleep(2)
# driver.quit()


from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
import time

driver = webdriver.Chrome(executable_path=r"D:\python\chromedriver.exe")
driver.get("http://121.43.169.97:8848/pageA.html")  # 注册页面A的URL
driver.maximize_window()

try:
    # 等待页面加载（显式等待更可靠）
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC

    # 先定位“注册”按钮，确保表达式正确（这里假设按钮value是“注册”，可根据实际页面调整）
    register_button = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.XPATH, "//input[@value='注册']"))
    )
    # 执行鼠标悬停操作
    action = ActionChains(driver)
    action.move_to_element(register_button).perform()

    time.sleep(3)  # 等待3秒观察效果

finally:
    driver.quit()